package com.lingx.web.api.impl;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.lingx.service.ModelService;
import com.lingx.utils.Utils;
import com.lingx.web.api.IApi;
@Component
public class Api9002 extends AbstractDevApi implements IApi{
	@Resource
	private JdbcTemplate jdbcTemplate;
	@Override
	public int getApiCode() {
		return 9002;
	}
	@Override
	public String getApiName() {
		return "获取模型列表";
	}

	@Override
	public Map<String, Object> api(Map<String, Object> param) {
		Map<String,Object> ret=IApi.getRetMap(1, "操作成功");
		String searchText=IApi.getParamString(param, "searchText", "");
		if(Utils.isNotNull(searchText)) {
			ret.put("data", this.jdbcTemplate.queryForList("select id,code,name from tlingx_entity where status='1' and (code like ? or name like ?) order by create_time desc","%"+searchText+"%","%"+searchText+"%"));
		}else {
			ret.put("data", this.jdbcTemplate.queryForList("select id,code,name from tlingx_entity where status='1' order by create_time desc"));
		}
		return ret;
	}

}
